var util = {
	options: {
		active_color: '#ff9800', //橘黄色
		normal_color: '#000',    //默认是黑色
		subPages: ['page1.html', 'page2.html']
	},
	drawNative: function(id, styles, tags) {  //绘制原生view控件对象
		var view = new plus.nativeObj.View(id, styles, tags);
		return view;
	},
	initSubPage: function() {
		var subpage_style = {
				top: 45,
				bottom: 51
			},
			subPages = util.options.subPages,
			self = plus.webview.currentWebview(),
			temp = {};
		
		if (mui.os.android) {//兼容安卓的添加titleNView 和设置沉浸式模式会遮盖子webview的内容
			if (plus.navigator.isImmersedStatusbar()) {
				subpage_style.top += plus.navigator.getStatusbarHeight();
			}
			if (current.getTitleNView()) {
				subpage_style.top += 40;
			}
		}
		temp[self.id] = 'true'; 
		mui.extend(aniShow, temp)//将temp对象扩展到aniShow身上
	},
	toggleNview: function(currentIndex) { //切换重绘tab高亮
		currentIndex = currentIndex * 2;
		util.updateView(currentIndex, util.options.active_color);//执行重绘
		util.updateView(currentIndex + 1, util.options.active_color);//执行重绘
		for (var i = 0; i < 8; i++) {
			if(i !== currentIndex && i !== currentIndex + 1) {
				util.updateView(i, util.options.normal_color);	
			}
		}
		
	},
	updateView: function(currentIndex, color) {//具体重绘的方法
		var self = plus.webview.currentWebview(),
			viewEvent = plus.nativeObj.View.getViewById('tabBar'),//获取view的控件对象
			viewObj = self.getStyle().subNViews[0],//获取nview对象的属性
			currentTag = nviewObj.tags[currentIndex]; //获取当前需要重绘的tag
		
		viewEvent.drawText(currentTag.text, currentTag.position, util.changeColor(currentTag.textStyles, color), currentTag.id);
	},
	changeColor: function(obj, color) {//改变颜色
		obj.color = color;
		return obj;
	}
}
